package com.wood.life.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * author: dz
 * 2022-10-25-10:03
 */

@Configuration
public class RabbitmqConfiguration {

    //交换机
    @Bean
    public TopicExchange exchangetopic() {
        return new TopicExchange("exchangetopic");
    }

    //队列
    @Bean
    public Queue queuequestion() {
        return new Queue("queuequestion");
    }

    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Binding bindingquestion(Queue queuequestion, TopicExchange exchangetopic) {
        return BindingBuilder.bind(queuequestion).to(exchangetopic).with("#.question.#");
    }

    //队列
    @Bean
    public Queue queueanswer() {
        return new Queue("queueanswer");
    }

    @Bean
    public Binding bindinganswer(Queue queueanswer, TopicExchange exchangetopic) {
        return BindingBuilder.bind(queueanswer).to(exchangetopic).with("#.answer.#");
    }

}
